﻿
using Xacml.Core.Interfaces;
using Xacml.Core.Runtime.Functions;

namespace Xacml.Core.Runtime.DataTypes
{
  public class HexBinary : IDataType
  {
    private byte[] _value;

    public IFunction EqualFunction
    {
      get
      {
        return (IFunction) new HexBinaryEqual();
      }
    }

    public IFunction IsInFunction
    {
      get
      {
        return (IFunction) new HexBinaryIsIn();
      }
    }

    public IFunction SubsetFunction
    {
      get
      {
        return (IFunction) new HexBinarySubset();
      }
    }

    public string DataTypeName
    {
      get
      {
        return "http://www.w3.org/2001/XMLSchema#hexBinary";
      }
    }

    internal HexBinary()
    {
    }

    public HexBinary(byte[] value)
    {
      this._value = value;
    }

    public override int GetHashCode()
    {
      return base.GetHashCode();
    }

    public override bool Equals(object obj)
    {
      if (!(obj is HexBinary))
        return base.Equals(obj);
      HexBinary hexBinary = (HexBinary) obj;
      if (this._value.Length != hexBinary._value.Length)
        return false;
      for (int index = 0; index < this._value.Length; ++index)
      {
        if ((int) this._value[index] != (int) hexBinary._value[index])
          return false;
      }
      return true;
    }
  }
}
